/*
 * @Date         : 2024-05-20 14:47:59 星期1
 * @Author       : xut
 * @Description  :
 */
import { z } from "zod"

export const createPostSchema = z.object({
  body: z.object({
    title: z.string(),
    content: z.string(),
    category: z.string(),
    published: z.boolean(),
    image: z.string(),
  }),
})

const params = {
  params: z.object({
    postId: z.string(),
  }),
}

export const getPostPageSchema = z.object({
  query: z.object({
    pageSize: z.string(),
    pageNo: z.string(),
    // title: z.string().optional(),
    // category: z.string().optional(),
    // published: z.boolean().optional(),
  }),
})

export const getPostSchema = z.object({
  ...params,
})

export const updatePostSchema = z.object({
  ...params,
  body: z
    .object({
      title: z.string(),
      content: z.string(),
      category: z.string(),
      published: z.boolean(),
      image: z.string(),
    })
    .partial(),
})

export const deletePostSchema = z.object({
  ...params,
})

export type GetPostPageInput = z.infer<typeof getPostPageSchema>["query"]
export type GetPostInput = z.infer<typeof getPostSchema>["params"]
export type CreatePostInput = z.infer<typeof createPostSchema>["body"]
export type UpdatePostInput = z.infer<typeof updatePostSchema>
export type DeletePostInput = z.infer<typeof deletePostSchema>["params"]
